package com.example.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import com.example.utilitaire.Stat_Boutique;

public class MySQliteCreator_Boutique extends SQLiteOpenHelper
{

	public MySQliteCreator_Boutique(Context context, String name,CursorFactory factory, int version)
	{
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) 
	{
		// TODO Auto-generated method stub
		
		String CMD_Article="CREATE TABLE "+Stat_Boutique.TABLE_NAME+" ("+Stat_Boutique.COL_ID+" INTEGER PRIMARY KEY autoincrement,"+Stat_Boutique.COL_REF+" VARCHAR(30)" +
				","+Stat_Boutique.COL_CONST+" VARCHAR(30),"+Stat_Boutique.COL_PRIX+" DOUBLE,"+Stat_Boutique.COL_CARACT+" VARCHAR(20))";
	    String CMD_Panier=" CREATE TABLE "+Stat_Boutique.TABLE_NAME_P+" ("+Stat_Boutique.COL_P_ID+" INTEGER PRIMARY KEY autoincrement,"+Stat_Boutique.COL_P_REF+" VARCHAR(30)" +
				","+Stat_Boutique.COL_P_PRIX+" DOUBLE,"+Stat_Boutique.COL_P_QUANTITY+" INTEGER )";
	
	    db.execSQL(CMD_Article);
	
	    db.execSQL(CMD_Panier);
	    
	    Log.d("Created", "Creation des 2 tables");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{
		 
        db.execSQL("DROP TABLE IF EXISTS " + Stat_Boutique.TABLE_NAME);
        db.execSQL("DROP TABLE IF EXISTS " + Stat_Boutique.TABLE_NAME_P);
        
        onCreate(db);
		
	}

}
